<template>
	<view>
		<view class="cardBox">
			<image :src="idCardFront" @tap="updataIDcard('a')" :class="updataImgA?'active':''"></image>
		</view>
		<view class="cardBox">
			<image :src="idCardReverse" @tap="updataIDcard('b')" :class="updataImgB?'active':''"></image>
		</view>
		<view class="tips">
			tips：拍照时务必保证画面清晰，五官可辨
		</view>
		<view class="upBtn">
			<button class="cu-btn block bg-blue margin-tb-sm lg">
				<text class="cuIconfont-spin" :class="upload?'cuIcon-loading2':''"></text>完成绑定
			</button>
		</view>
		<view class="footHint">
			<image src="../../static/idCard/secure.png" mode=""></image>
			<text>信息已加密，保证您的财产安全</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				idCardFront: '../../static/idCard/idCardFront.png',
				idCardReverse: '../../static/idCard/idCardReverse.png',
				updataImgA: false,
				updataImgB: false,
				upload:false
			}
		},
		methods: {
			updataIDcard(updataImg) {
				// console.log(updataImg)
				uni.chooseImage({
					count: 4, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res) => {
						console.log(res);
						if (updataImg == 'a') {
							this.updataImgA = true;
							this.idCardFront = res.tempFilePaths;
						}
						else if(updataImg == 'b'){
							this.updataImgB = true;
							this.idCardReverse = res.tempFilePaths;
						}
					}
				});

			}
		}
	}
</script>

<style lang="scss">
	.cardBox {
		width: 670upx;
		height: 360upx;
		margin: 0 auto;
		background-color: #F4f8ff;
		margin-top: 30upx;
		border-radius: 12upx;
		display: flex;
		align-items: center;
		justify-content: center;

		image {
			width: 450upx;
			height: 280upx;
		}

		.active {
			width: 670upx;
			height: 360upx;
			padding: 40upx;
			box-shadow: 0 0 20upx rgba(0, 0, 0, 0.1);
		}
	}

	.tips {
		width: 70vw;
		font-size: 28upx;
		color: #868686;
		margin: 70upx auto;
	}
	
	.upBtn{
		border-radius: 8upx;
		.cu-btn{
			height: 95upx;
		}
		button{
			width: 670upx;
			margin: 0 auto;
			background-color: #3476f1;
		}
	}
	.footHint{
		width: 50vw;
		margin: 224upx
		 
		 auto;
		display: flex;
		align-items: center;
		image{
			width: 22upx;
			height: 26upx;
			margin-right: 14upx;
		}
		text{
			font-size: 24upx;
			color: #868686;
		}
	}
</style>
